<?php

namespace app\app\controller\shop;

use app\app\controller\AppBase;
use app\app\model\shop\ShopGoodsModel;
use app\app\validate\shop\ShopGoodsValidate;

class ShopGoods extends AppBase
{
    protected $noNeedLogin = [];


    /**
     * Notes: 商品列表
     * User: AerYYY
     * Date: 7/2/25
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function list()
    {
        $shopGoodsModel = new ShopGoodsModel();
        $list = $shopGoodsModel->list($this->params);
        $this->success($list);
    }


    /**
     * Notes: 商品详情
     * User: AerYYY
     * Date: 7/2/25
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function info()
    {
        $validate = new ShopGoodsValidate();
        if (!$validate->scene('info')->check($this->params)) {
            $this->error($validate->getError());
        }

        $shopGoodsModel = new ShopGoodsModel();
        $info = $shopGoodsModel->info($this->params);

        $info['sku'] = $shopGoodsModel->getSku($this->params);

        $this->success($info);
    }
}